package com.chiry.shop.goods.service.impl;

import com.chiry.common.vo.Result;
import com.chiry.common.bo.goods.GoodsBO;
import com.chiry.shop.goods.mapper.GoodsMapper;
import com.chiry.shop.goods.pojo.Goods;
import com.chiry.shop.goods.service.GoodsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author fyx
 * @version 1.0
 * @date 2021/12/9 19:37
 */
@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    GoodsMapper goodsMapper;
    @Override
    public Result<GoodsBO> findGoodsById(Long id) {
        Goods goods = goodsMapper.selectById(id);
        if (goods == null) {
            return Result.fail(10001, "商品信息不存在");
        }
        GoodsBO goodsBO = new GoodsBO();
        BeanUtils.copyProperties(goods, goodsBO);
        return Result.success(goodsBO);
    }
}
